package com.pdlocation.model;

import java.io.Serializable;

//位置数据模型
public class LocationPoint implements Serializable {
    private double latitude;//纬度
    private double longitude;//经度
    private double altitude;//海拔
    private float accuracy;//精度
    private long timestamp;//时间
    private int source; // 来源 0:GPS, 1:Network, 2:Fused
    private int satelliteCount;// 卫星颗数
    private boolean hasAltitude;//
    private String address;// 位置

    public LocationPoint(double latitude, double longitude, double altitude, float accuracy, long timestamp, int source, int satelliteCount, boolean hasAltitude, String address) {
        this.latitude = latitude;
        this.longitude = longitude;
        this.altitude = altitude;
        this.accuracy = accuracy;
        this.timestamp = timestamp;
        this.source = source;
        this.satelliteCount = satelliteCount;
        this.hasAltitude = hasAltitude;
        this.address = address;
    }

    // Getters and setters
    public double getLatitude() { return latitude; }
    public double getLongitude() { return longitude; }
    public double getAltitude() { return altitude; }
    public float getAccuracy() { return accuracy; }
    public long getTimestamp() { return timestamp; }
    public int getSource() { return source; }
    public int getSatelliteCount() { return satelliteCount; }
    public boolean hasAltitude() { return hasAltitude; }
    public String getAddress() { return address; }

    public String getSourceName() {
        switch (source) {
            case 0: return "GPS";
            case 1: return "网络";
            case 2: return "融合";
            default: return "未知";
        }
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("位置点[");
        sb.append("纬度: ").append(latitude);
        sb.append(", 经度: ").append(longitude);
        if (hasAltitude) {
            sb.append(", 海拔: ").append(altitude).append("米");
        }
        sb.append(", 精度: ").append(accuracy).append("米");
        sb.append(", 来源: ").append(getSourceName());
        if (source == 0 || source == 2) {
            sb.append(", 卫星数: ").append(satelliteCount);
        }
        sb.append(", 时间: ").append(timestamp);
        sb.append("]");
        return sb.toString();
    }
}
